const http = require('http');
const fs = require('fs');
const stream = fs.createReadStream('./test.js');

http.createServer(function(req, res){
    res.writeHead(200, {
        'Content-Type': 'text/javascript'
    });
    stream.pipe(res);
}).listen(3000);

stream.on('data', function(chunk){
    console.log('chunk:' + chunk)
})

stream.on('end', function(chunk){
    console.log('finished')
})

fs.readFile('./test.json', function(er, data){
    console.log('fs:' + data);
})